Fix reactive streams MongoClient.getTimeout always returning null#2009
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the Reactive Streams driver’s MongoClient.getTimeout(TimeUnit) implementation so it reports the configured operation timeout (instead of always returning null), and aligns nullability annotations with the public API contract.
Changes:
- Reactive Streams:
MongoClientImpl.getTimeoutnow delegates to the underlying cluster implementation. - Reactive Streams + Sync: add
@NullabletogetTimeoutoverrides to match theMongoClusterAPI contract.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| driver-sync/src/main/com/mongodb/client/internal/MongoClientImpl.java | Adds @Nullable to getTimeout override to match MongoCluster#getTimeout contract. |
| driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/MongoClusterImpl.java | Adds @Nullable to getTimeout override (note: conversion logic in this method needs correction per review comment). |
| driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/MongoClientImpl.java | Fixes Reactive Streams MongoClient.getTimeout to delegate instead of always returning null; marks return as @Nullable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rozza
left a comment
There was a problem hiding this comment.
I'd recommend adding notNull checks for timeUnit - but understand your motiviations for not adding it.
LGTM
JAVA-6246
Done in 0acc7ec. |
| @Override | ||
| @Nullable | ||
| public Long getTimeout(final TimeUnit timeUnit) { | ||
| notNull("timeUnit", timeUnit); |
There was a problem hiding this comment.
I added the notNull checks to MongoClusterImpl and not MongoClientImpl to be consistent with the rest of the code. However, the approach is wrong, and the checks should be in MongoClientImpl instead, because at run time an application directly calls methods of MongoClientImpl, not MongoClusterImpl.
AI was used only to review.
JAVA-6246